package cn.gov.msa.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.PageHelper;

import cn.gov.msa.dao.DictionaryMapper;
import cn.gov.msa.dao.FileMapper;
import cn.gov.msa.dao.NoticeMapper;
import cn.gov.msa.model.Dictionary;
import cn.gov.msa.model.File;
import cn.gov.msa.model.Notice;
import cn.gov.msa.pagehelper.CustomPageHelper;
import cn.gov.msa.service.NoticeService;

public class NoticeServiceImpl implements NoticeService{
	
	@Autowired
	private NoticeMapper noticeMapper;
	
	@Autowired
	private FileMapper fileMapper;

	@Override
	@Transactional
	public List<Notice> selectAllData(int pageNum, int pageSize, Notice notice){
		CustomPageHelper.startPage(pageNum, pageSize); // 核心分页代码  
		List<Notice> listNotice = noticeMapper.selectAllData(notice);
		
		return listNotice;	
	}
	
	@Override
	@Transactional
	public List<Notice> selectNotice(int pageNum, int pageSize, Notice notice) {
		CustomPageHelper.startPage(pageNum, pageSize); // 核心分页代码  
		List<Notice> listNotice = noticeMapper.selectData(notice);
		
		return listNotice;
	}


	@Override
	@Transactional
	public boolean saveData(Notice notice) {
		boolean result = false;
		int result1 = noticeMapper.saveData(notice);
		if (result1 > 0) {
			result = true;
		}
		return result;
	}
	
	@Override
	@Transactional
	public boolean updateNotice(Notice notice) {
		boolean result = false;
		int result1 = noticeMapper.updateNotice(notice);
		if (result1 > 0) {
			result = true;
		}
		return result;
	}
	


	@Override
	@Transactional
	public int deleteNotice(String noticeId) {
		return noticeMapper.deleteNotice(noticeId);
	}


	@Override
	@Transactional
	public int updateNoticeFileId(Notice notice) {		
		return noticeMapper.updateNoticeFileId(notice);
	}


	@Override
	@Transactional
	public File selectFile(String fileId) {
		return fileMapper.selectFile(fileId);
	}
	
	@Override
	@Transactional
	public List<Notice> selectwaiData(int pageNum, int pageSize){
		CustomPageHelper.startPage(pageNum, pageSize); // 核心分页代码  
		return noticeMapper.selectwaiData();
	};


	

}
